package com.itheima.mm.controller;

import com.itheima.mm.base.BaseController;
import com.itheima.mm.entity.Result;
import com.itheima.mm.pojo.Company;
import com.itheima.mm.service.CompanyService;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ShenHD
 * @Date 2021/8/11
 */

@RestController
@RequestMapping("/company")
@Slf4j
public class CompanyController extends BaseController {
    @Autowired
    private CompanyService companyService;

    @GetMapping("/findListAll")
    public Result findListAll() {
        try {
            log.info("findListAll");
            List<Company> companyList = companyService.findListAll();
            return new Result(true, "获取成功", companyList);
        } catch (Exception e) {
            log.error("findListAll", e);
            return new Result(false, "获取失败:" + e.getMessage());
        }
    }
}
